{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/defau.css">
<style>
.table-input{
	height:12px !important;
	line-height:12px !important;
	width:30px;
	margin-bottom:0px !important;
}
</style>
{/block}
{block name="main"}
<div class="mod-table">
	<div class="mod-table-head">
		<div class="con style0list">
			<table>
				<colgroup>
					<col style="width: 10%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
				</colgroup>
				<thead>
					<tr>						
						<th>等级名称</th>
						<th>全球分红分值</th>
						<th>全球分红权重</th>
						<th>创建时间</th>
					</tr>
				</thead>
				<colgroup>
					<col style="width: 10%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
					<col style="width: 15%;">
				</colgroup>
				<tbody  id="partner_global">
				{foreach name="partner_level_list" item="partner_level_info" }
				    <tr align="center" data-level_id={$partner_level_info.level_id}>
						<td>{$partner_level_info.level_name}</td>
						<td><input  class="table-input" type="text" value="{$partner_level_info.global_value}" /></td>
						<td><input  class="table-input"  type="text" value="{$partner_level_info.global_weight}" /></td>
						<td>{$partner_level_info.create_time}</td>
					</tr>					
				{/foreach}
				</tbody>
			</table>
		</div>
	</div>
	<dl>
		<dt></dt>
		<dd>
		<button class="btn-common btn-big" onclick="updateGlobalBonusPoolConfig();">提交</button>
		</dd>
	</dl>
</div>

<script>		
function updateGlobalBonusPoolConfig(){
	var trObj = $("#partner_global");
	var partner_level_string = "";
	$("#partner_global tr").each(function() {
		var level_id = $(this).data("level_id");
		var global_value = $(this).children().eq(1).children("input").val();
		var global_weight = $(this).children().eq(2).children("input").val();
		partner_level_string = partner_level_string + ";" + level_id + "," + global_value + "," + global_weight;
	});
	partner_level_string = partner_level_string.substring(1, partner_level_string.length );
	$.ajax({
		type:"post",
		url:"{:__URL('__URL__/nsfx/ADMIN_MODULE/Distribution/updateGlobalBonusPoolConfig')}",
		data:{
			'partner_level_string':partner_level_string
		},
		success:function (data) {
			if (data["code"] > 0) {
				showMessage('success', data["message"],"{:__URL('__URL__/nsfx/ADMIN_MODULE/Distribution/updateGlobalBonusPoolConfig')}");
			}else{
				showMessage('error', data["message"]);
			}	
		}
	});
}

</script>
{/block}